<template>
	<view>
        <view class="u-page" v-if="listPageConfig">
            <commonListPage :config="listPageConfig" ref="mylp"></commonListPage>
        </view>
        <!-- <mytabbar></mytabbar> -->
	</view>
</template>

<script>
	import mytabbar from '@/components/tabbar/index.vue';
    import commonListPage from '@/components/commonListPage/commonListPage.vue';
	export default {
		components: {
            mytabbar: mytabbar,
            commonListPage: commonListPage
        },
		data() {
			return {
				listPageConfig: ''
			}
		},
		onShareAppMessage(options) {
			var shareObj = {tab: 1, tabUrl: '/pages/activity/index'};
			return {
				title: '志愿活动',
				path: 'pages/index/index?share=' + encodeURIComponent(JSON.stringify(shareObj)),
				success(res) {
					uni.showToast({
					title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
					title: '分享失败',
					icon: 'none'
					})
				}
			}
		},
		onLoad() {
            this.doWxLogin().then(res => {
                this.openId = res.openId;
				this.initConfig();
            })
		},
		onReachBottom() {
			this.$refs.mylp.cmpReachBottom();
		},
		options: { styleIsolation: 'shared' },
		methods: {
			___initConfig() {
				// 文档库的配置
				var json = {
					categories: [
						{
							name: '收藏',
							listConfig: {
								listApi: '/mobile/mpoa/content/getCollectList.json?openId=【openId】',
								mapper: {
									lens: [
										{
											lenStyle: '',
											items: [ { label: '收藏时间', template: '【collectTime】' } ]
										}
									]
								}
							}
						}, {
							name: '共享',
							listConfig: {
								listApi: '/mobile/mpoa/content/getList.json?openId=【openId】',
								mapper: {
									lens: [
										{
											lenStyle: '',
											items: [ { label: '创建时间', template: '【createTime】' } ]
										}
									]
								}
							}
						}
					],
					toolBar: {
						searchBar: {
							value: '',
							placeholder: '请输入标题'
						}
					},
					listConfig: {
						pageSize: 10,
						total: 0,
						mapper: {
							title: '[【createUser】]【filename】',
							iconConfig: {
								type: 'file',
								targetProp: 'filename',
							}
						}
					}
				};
                
				this.listPageConfig = json;
			},
			initConfig: function () {
				var vm = this;
				var loadJSON = '/wxAssets/wxJSON/志愿活动/list.json';
				vm.getAndLoad('获取列表页配置', loadJSON, function (res) {
					vm.listPageConfig = res;
					if (res.title) {
						uni.setNavigationBarTitle({
							title: res.title
						});
					}
				});
			}
			
		}
	}
</script>

<style lang="scss" scoped>
</style>

